<p>
This is an automated monthly status report of the best practices
badge application covering the month <%= @month_display %>.

<% if @last_stat_in_prev_month && @last_stat_in_prev_prev_month %>
<p>
Here are some selected statistics for most recent completed month,
preceded by the same statistics for the end of the month before that.

<table border="1">
<tr><th>Ending dates</th><td><%=
  @last_stat_in_prev_prev_month.created_at.strftime('%Y-%m-%d')
%></td><td><%=
  @last_stat_in_prev_month.created_at.strftime('%Y-%m-%d')
%></td></tr>
<% Project::LEVEL_IDS.each do |level|
     ProjectStat::STAT_VALUES.each do |percentage|
        next if level.to_i != 0 && percentage.to_i.zero?
%><tr><th><%= ProjectStat.percent_field_description(level, percentage)
%></th><td><%=
    @last_stat_in_prev_prev_month[
      ProjectStat.percent_field_name(level, percentage)]
%></td><td><%=
    @last_stat_in_prev_month[
      ProjectStat.percent_field_name(level, percentage)]
%></td></tr>
<%    end
   end %>
</table>
<% end %>

<%
new_achievements = false
Project::LEVEL_ID_NUMBERS.each do |level|
  if @projects[level] && !@projects[level].blank? %>
<p>
Here are the projects that first achieved a
<%= t("projects.form_early.level.#{level}") %> badge in <%= @month_display %>:

<ol>
<%
    @projects[level].each do |project|
      new_achievements = true
%>
<li><a href="https://<%= @hostname %>/projects/<%= project.id %>"><%= project.name %> at <%= project.achieved_passing_at %></a>
<%
    end # each
%>
</ol>

<%
  end # if there are projects
end # each level
%>

<%
if new_achievements
%>
<p>
We congratulate them all!
<%
end
%>

<p>
Do you know a project that doesn't have a badge yet?
Please suggest to them that they
<a href="https://<%= @hostname %>/">get a badge now</a>!
